// 宿舍管理
import httpInstance from "./http";

// 1、获取所有的学生信息api
export const getStudentApi = (type, sno) => {
    return httpInstance.get("/students", {
        params: { type, sno }
    });
}

// 2、打开添加面板获取年级和宿舍楼
export const getGradeInfoApi = () => {
    return httpInstance.get('/get_grade');
}

// 3、在选择宿舍楼后，根据宿舍楼的id值获取还有空余床位的宿舍号
export const getRoomNameApi = (building) => {
    return httpInstance.get("/available_room_name", {
        params: { building }
    })
}

// 4、选择完宿舍号后，根据宿舍号的id获取空余的床位号
export const getBedNumberApi = (id) => {
    return httpInstance.get('/bed_number', {
        params: { id }
    })
}

// 5、提交表单数据
export const submitFormApi = (form) => {
    return httpInstance.post('/add_student', {
        data: form
    })
}

// 6、学生信息添加成功后，修改床位号
export const updateBedNumberApi = (bedId, dorId, type) => {
    return httpInstance.put('/update_bedNumber', { bedId, dorId, type });
}

// 7、搜索学生信息
export const searchStudentApi = (key, value) => {
    return httpInstance.get('/search_student', {
        params: { key, value }
    })
}

// 8、删除学生信息
export const delStudentInfoApi = (sno) => {
    return httpInstance.delete('/del_student', {
        params: { sno }
    })
}

// 9、学生退宿
export const stuRetreatApi = (sno) => {
    return httpInstance.put(`/stu_retreat/${sno}`)
}

// 10、编辑
export const editStudentApi = (form) => {
    return httpInstance.put('/edit_student', form)
}